package com.example.zhaoping.serviceImpl;

import com.baomidou.mybatisplus.annotation.Version;
import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
import com.example.zhaoping.entity.Admin;
import com.example.zhaoping.entity.User;
import com.example.zhaoping.mapper.AdminMapper;
import com.example.zhaoping.service.AdminSerice;
import org.springframework.stereotype.Service;

import javax.annotation.Resource;

@Service
public class AdminServiceImpl implements AdminSerice {

    @Resource
    private AdminMapper adminMapper;

    @Override
    public Admin selectByUserName(Admin admin) {
        QueryWrapper<Admin> queryWrapper = new QueryWrapper<>();
        queryWrapper.eq("username",admin.getUsername());
        return adminMapper.selectOne(queryWrapper);
    }

    @Override
    public Admin selectAdminById(int id) {
        return adminMapper.selectById(id);
    }

    @Override
    public Admin adminLogin(Admin admin){
        QueryWrapper<Admin> queryWrapper = new QueryWrapper<>();
        queryWrapper.eq("username",admin.getUsername())
                .eq("password",admin.getPassword());
        return adminMapper.selectOne(queryWrapper);
    }


}
